<?php
namespace Data;

use Data\Drive\DataCache;

class Delete extends \Data
{
    public static function Run($conf)
    {
        if (!is_array($conf)) {
            self::Error("删除SQL必须为数组格式", __FILE__, __LINE__);
        }
        $sql  = "DELETE FROM {$conf['table']} WHERE {$conf['where']}";
        $num  = self::$db->exec($sql);
        $code = self::$db->errorCode();
        if ($code != 00000) {
            $info = self::$db->errorInfo();
            self::Error(json_encode($info) . "\r\n" . $sql, __FILE__, __LINE__);
        }
        DataCache::clearCache($conf['table']);
        return ["state" => "ok", "msg" => "操作成功", "num" => $num];
    }
}
